package com.example.springbootdemo;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
@Data
@ConfigurationProperties("demo")
public class DemoProperties {

    // @Value("zhangsan")  // 静态设置
    @Value("${demo.name}")
    private String name;
    @Value("${demo.age}")
    private int age;
    // @Value("${demo.schools}")   不支持复杂属性
    private String[] schools;

    private Map<String,String> familys;

    private List<Map<String,Object>> dogs;

    private List<Friend> friends;
}

@Data
class Friend{
    private String name;
    private int age;
    List<String> likes;
}

